<!DOCTYPE html>
<html>
<head>
    

    <include file="Common/head"/>

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>用户列表</h5>
        </div>
        <div class="ibox-content">
            <div class="row row-lg">
                
                <div class="col-sm-12">
                    <div class="clearfix" style="width:100%;">
                        <div class="bars pull-left"><div class="btn-group hidden-xs" id="exampleTableEventsToolbar" role="group">
                            <button type="button" class="btn btn-outline btn-default" href="{:U('Auth/index')}">
                                <i class="glyphicon glyphicon-chevron-left" aria-hidden="true"></i>
                            </button>
                            <button class="btn btn-default btn-outline" type="button" name="refresh" title="刷新" href="__SELF__"><i class="glyphicon glyphicon-repeat"></i></button>
                        </div></div>
                        <div class="columns columns-right btn-group pull-right" style="margin-left: 5px;">
                            <button type="button" class="btn btn-outline btn-default" onclick="add2group()">
                                <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>
                            </button>
                        </div>
                        <div class="pull-right search">
                            <input class="form-control input-outline" type="text" name="uid" placeholder="用户UID,多个用逗号隔开">
                            <input type="hidden" name="group_id" value="{:I('group_id')}">
                        </div>
                        <script>
                            function add2group(){
                                console.log('flag');
                                var uid = $("input[name='uid']").val(),
                                    group_id = $("input[name='group_id']").val(),
                                    data = {uid:uid, group_id:group_id};
                                console.log(data);
                                if (data.uid) {
                                    console.log('flag1');
                                } else {
                                    console.log('flag2');
                                }
                                $.post(
                                    "{:U('Auth/addToGroup')}",
                                    data,
                                    function(res){
                                        console.log(res);
                                        if (parseInt(res.status) === 1) {
                                            // TODO:添加成功，跳转
                                        } else {
                                            // TODO:添加失败
                                            alert(res.msg);
                                        }
                                        window.location.reload();
                                    },
                                    'json'
                                );
                            }
                        </script>
                    </div>
                    <div class="table-responsive">
                        <form id="form" method="post">
                            <table class="table table-hover">
                                <thead>
                                <tr>
                                    <th>UID</th>
                                    <th>用户名</th>
                                    <th>最后登录时间</th>
                                    <th>最后登录IP</th>
                                    <th>状态</th>
                                    <th style="text-align: center">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <volist name="list" id="info">
                                        <tr>
                                            <td>{$info.uid}</td>
                                            <td><a href="{:U('User/edit',['uid'=>$info['uid']])}">{$info.username}</a></td>
                                            <td>{$info.last_login_time|date='Y-m-d H:i:s',###}</td>
                                            <td>{$info.last_login_ip|long2ip}</td>
                                            <td>{$info.status_text}</td>
                                            <td style="text-align: center">
                                                <button type="button" class="btn btn-sm btn-danger confirm" href="{:U('Auth/removeFromGroup',array('uid'=>$info['uid'],'group_id'=>I('group_id')))}">
                                                    解除授权
                                                </button>
                                            </td>
                                        </tr>
                                </volist>
                                </tbody>
                            </table>
                        </form>
                    </div>
    
                    <ul class="pagination">
                        {$page}
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <!-- End Panel Other -->
</div>
<include file="Common/footer"/>
<script src="__JS__/content.min.js?v=1.0.0"></script>
</body>
</html>
